package com.jr.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jr.entity.Post;
import com.jr.service.impl.PostServiceImpl;
import com.jr.util.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;

@RestController
public class PostController {
    @Autowired
    private PostServiceImpl postService;
    @RequestMapping("/findAlljob")
    private Result find(Post post,Integer indexpage){

            if (indexpage==null){
                PageHelper.startPage(1,2);
            }else {
                PageHelper.startPage(indexpage,2);
            }
        ArrayList<Post> list=postService.findAllPosts(post);
            PageInfo<Post> info=new PageInfo<>(list);
            return Result.success(info);
        }
        @RequestMapping("/findj")
    private Result findj(Post post,Integer indexpage){

        ArrayList<Post> list=postService.findAllPosts(post);

            return Result.success(list);
        }
        @RequestMapping("/tsearchjob")
    private ModelAndView tiaosearchjob(String uid){
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("uid",uid);
        modelAndView.setViewName("searchJob");
        return modelAndView;
        }

}


